package com.farecrawler.junit;

import junit.framework.TestCase;
import junitx.util.PrivateAccessor;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class BaseFareCrawlTestCase extends TestCase {
	
	private static final String CONTEXT_FILE = 
		"D:/Springsource/workspace/farecrawler_google/war/WEB-INF/dispatcher-servlet.xml";
	
	private ApplicationContext ctx;
	private Object testObject;
	
	public BaseFareCrawlTestCase() {
		setup();
	}
	
	@SuppressWarnings("rawtypes")
	public Object invokePrivate(String methodName, Class[] argType, Object[] args) {
		
		Object result = null;
		try {
			result = PrivateAccessor.invoke(testObject, methodName, argType, args);
		}catch(Throwable t) {
			t.printStackTrace();
			fail(t.getMessage());
		}
		return result;
	}
	
	private void setup() {
		ctx = new FileSystemXmlApplicationContext(CONTEXT_FILE);
	}
	
	/*
	 * Getters Setters
	 */
	public ApplicationContext getCtx() {
		return ctx;
	}
	public void setCtx(ApplicationContext ctx) {
		this.ctx = ctx;
	}
	public Object getTestObject() {
		return testObject;
	}
	public void setTestObject(Object testObject) {
		this.testObject = testObject;
	}

}
